import random as rd
fo = open("homework.txt","w+")
print("1.一百以内连减")
print("2.一百以内连加")
print("3.一百以内混加减")
print("4.十以内连减")
print("5.十以内连加")
print("6.十以内混加减")
keyvalue = int(input("输入类型（数字输入）"))
keynum =int(input("输入需要的题量（数字输入）"))
def subtraction100(num0):
    judge = 2
    for i in range(num0):
        a = rd.randint(30, 100)
        b = rd.randint(5, 100)
        c = rd.randint(5, 100)
        while a < b + c:
            b = rd.randint(5, 100)
            c = rd.randint(5, 100)
        work = (str(a) + "-" + str(b) + "-" + str(c) + "=")

        if judge == 2:
            fo.writelines(work)
            fo.writelines("                     ")
            judge -= 1
            continue
        if judge == 1:
            fo.writelines(work)
            fo.writelines("                     ")
            judge -= 1
            continue
        if judge == 0:
            fo.writelines(work)
            fo.writelines("\r\n")
            judge = 2
def plus100(num0):
    judge = 2
    for i in range(num0):
        a = rd.randint(1, 80)
        b = rd.randint(5, 50)
        c = rd.randint(5, 50)
        while a + b + c>100:
            b = rd.randint(5, 100)
            c = rd.randint(5, 100)
        work = (str(a) + "+" + str(b) + "+" + str(c) + "=")

        if judge == 2:
            fo.writelines(work)
            fo.writelines("                     ")
            judge -= 1
            continue
        if judge == 1:
            fo.writelines(work)
            fo.writelines("                     ")
            judge -= 1
            continue
        if judge == 0:
            fo.writelines(work)
            fo.writelines("\r\n")
            judge = 2


def substrationANDPlus100(num0):
    judge = 2
    for i in range(num0):
        a = rd.randint(1, 80)
        b = rd.randint(5, 50)
        c = rd.randint(5, 50)
        d = rd.randint(1,2)
        if d ==1:
            while a+b-c>100:
                b = rd.randint(5, 50)
                c = rd.randint(5, 50)
            work = (str(a) + "+" + str(b) + "-" + str(c) + "=")
            if judge == 2:
                fo.writelines(work)
                fo.writelines("                     ")
                judge -= 1
                continue
            if judge == 1:
                fo.writelines(work)
                fo.writelines("                     ")
                judge -= 1
                continue
            if judge == 0:
                fo.writelines(work)
                fo.writelines("\r\n")
                judge = 2
        else:
            while a-b+c>100:
                b = rd.randint(5, 50)
                c = rd.randint(5, 50)
            work = (str(a) + "-" + str(b) + "+" + str(c) + "=")
            if judge == 2:
                fo.writelines(work)
                fo.writelines("                     ")
                judge -= 1
                continue
            if judge == 1:
                fo.writelines(work)
                fo.writelines("                     ")
                judge -= 1
                continue
            if judge == 0:
                fo.writelines(work)
                fo.writelines("\r\n")
                judge = 2
def subtraction10(num0):
    judge = 2
    for i in range(num0):
        a = rd.randint(1, 10)
        b = rd.randint(1, 5)
        c = rd.randint(0, 1)
        while a < b + c:
            b = rd.randint(0, 5)
            c = rd.randint(0, 5)
        work = (str(a) + "-" + str(b) + "-" + str(c) + "=")

        if judge == 2:
            fo.writelines(work)
            fo.writelines("                     ")
            judge -= 1
            continue
        if judge == 1:
            fo.writelines(work)
            fo.writelines("                     ")
            judge -= 1
            continue
        if judge == 0:
            fo.writelines(work)
            fo.writelines("\r\n")
            judge = 2
def plus10(num0):
    judge = 2
    for i in range(num0):
        a = rd.randint(0, 5)
        b = rd.randint(0, 7)
        c = rd.randint(0, 4)
        while a + b + c>10 and a != b != c:
            b = rd.randint(0, 7)
            c = rd.randint(0, 4)
        work = (str(a) + "+" + str(b) + "+" + str(c) + "=")

        if judge == 2:
            fo.writelines(work)
            fo.writelines("                     ")
            judge -= 1
            continue
        if judge == 1:
            fo.writelines(work)
            fo.writelines("                     ")
            judge -= 1
            continue
        if judge == 0:
            fo.writelines(work)
            fo.writelines("\r\n")
            judge = 2


def substrationANDPlus10(num0):
    judge = 2
    for i in range(num0):
        a = rd.randint(1, 8)
        b = rd.randint(0, 5)
        c = rd.randint(0, 5)
        d = rd.randint(1,2)
        if d ==1:
            while a+b-c>10 and a != b != c:
                b = rd.randint(5, 50)
                c = rd.randint(5, 50)
            work = (str(a) + "+" + str(b) + "-" + str(c) + "=")
            if judge == 2:
                fo.writelines(work)
                fo.writelines("                     ")
                judge -= 1
                continue
            if judge == 1:
                fo.writelines(work)
                fo.writelines("                     ")
                judge -= 1
                continue
            if judge == 0:
                fo.writelines(work)
                fo.writelines("\r\n")
                judge = 2
        else:
            while a-b+c>10 and a != b != c:
                b = rd.randint(0, 5)
                c = rd.randint(1, 5)
            work = (str(a) + "-" + str(b) + "+" + str(c) + "=")
            if judge == 2:
                fo.writelines(work)
                fo.writelines("                     ")
                judge -= 1
                continue
            if judge == 1:
                fo.writelines(work)
                fo.writelines("                     ")
                judge -= 1
                continue
            if judge == 0:
                fo.writelines(work)
                fo.writelines("\r\n")
                judge = 2




if keyvalue == 1:
    subtraction100(keynum)
elif keyvalue == 2:
    plus100(keynum)
elif keyvalue == 3:
    substrationANDPlus100(keyvalue)
elif keyvalue == 4:
    plus10(keynum)
elif keyvalue == 5:
    substrationANDPlus10(keyvalue)
elif keyvalue == 6:
    plus10(keynum)
else:print("error")